﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MMITDomain.Abstract;
using MMITDomain.Entities;

namespace MMITDomain.Concrete
{
    public class EFTransactionRoleAccountRepository : ITransactionRoleAccountRepository
    {
        EFDbContext dbContext = new EFDbContext();
        
        #region ITransactionRoleAccountRepository Members

        public IQueryable<TransactionRoleAccount> TransactionRoleAccounts
        {
            get
            {
                return dbContext.TransactionRoleAccounts;
            }
        }

        public void SaveTransactionRoleAccount(TransactionRoleAccount objTransactionRoleAccount)
        {
            if (objTransactionRoleAccount.Id == 0)
            {
                dbContext.TransactionRoleAccounts.Add(objTransactionRoleAccount);
            }

            dbContext.SaveChanges();
        }

        public void DeleteTransactionRoleAccount(TransactionRoleAccount objTransactionRoleAccount)
        {
            dbContext.TransactionRoleAccounts.Remove(objTransactionRoleAccount);

            dbContext.SaveChanges();
        }

        public TransactionRoleAccount GetTransactionRoleAccountById(int iTransactionRoleAccountId)
        {
            return dbContext.TransactionRoleAccounts.Find(iTransactionRoleAccountId);
        }

        #endregion
    }
}
